﻿#ifndef LOADINGDIALOG_H
#define LOADINGDIALOG_H
/**************************************************
 * LoadingDialog加载提示
 * 可以弹窗来阻塞主线程，等待后台执行某一费时操作结束，例如相机枚举
 * 
 **************************************************/

#include <QDialog>
#include <QMovie>
#include <QTimer>
#include <QtConcurrent/QtConcurrent>
#include <QThread>

namespace Ui {
	class LoadingDialog;
}

class TimerThread : public QThread 
{
	Q_OBJECT
public:
	TimerThread(QObject* parent); 
protected:
	void run() override;
signals:
	void SigUpdate();
};

class LoadingDialog : public QDialog
{
	Q_OBJECT

public:
	explicit LoadingDialog(QWidget* parent = nullptr);
	~LoadingDialog();

    //显示loading窗
    static void Loading(QWidget* parent = nullptr);
	static void ProcessEvent();
    //隐藏loading窗
    static void HideLoading();

private slots:
	void on_Close_Button_clicked();
	void on_Process_Once();

private:
	Ui::LoadingDialog* ui;
    QMovie* m_pLoadingMovie;
	TimerThread* m_pTimerThread;
};

#endif // LOADINGDIALOG_H
